// app.js

let d =  require('./utils/dataProvince.js')
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    this.getHistory()
    d.getData().then(r=>{
      // let dataMap  = [{name:"四川",value:"2999"}]
      // console.log(r)
      r.forEach(item=>{
          item.value = item.total.confirm
      })

      this.globalData.confirmMap = r

    })
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  getHistory(){
    wx.request({
      url: 'https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=chinaDayList,chinaDayAddList,nowConfirmStatis,provinceCompare',
      success:(r) => {
   

          let  t  =r.data.data.chinaDayList 
        //   x轴的数据

        let x = t.map(item=>{
            return item.date
        })
       this.globalData.xdata = x
        // y1确诊的数据

        let y1 =  t.map(item=>{
            return item.confirm
        })
       this.globalData.comData = y1
        let y2 =t.map(item=>{
          return item.heal
        })
        this.globalData.healData = y2
      }
    })
  },
  globalData: {
    userInfo: null,
    xdata:null,
    comData:null,
    healData:null,
  }
})
